﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace weclever
{
    public static class SiteUrls
    {
        #region Constants

        private const string _domain = "weclever.ru";
        private const string _baseUrl = "http://www.weclever.ru";
        private const string _imgDir = "imgs";
        private const string _dataDir = "data";

        
        #endregion
        
        public  static string Site { get { return _baseUrl; } }

        public static string ImgsDirectory
        {
            get
            {
                if (!Directory.Exists(_imgDir))
                {
                    Directory.CreateDirectory(_imgDir);
                }
                return _imgDir;
            }
        }

        public static string DataDirectory
        {
            get
            {
                if (!Directory.Exists(_dataDir))
                {
                    Directory.CreateDirectory(_dataDir);
                }
                return _dataDir;
            }
        }
        private static string Domain { get { return _domain; } } // it's need for parsing

        #region MakeAdress
        public static string MakeAddress(string city)
        {
            return String.Format("{0}/{1}", Site, city);
        }

        public static string MakeAddress(string city, string param)
        {
            return String.Format("{0}/{1}/{2}", Site, city, param);
        }
        #endregion

        #region Parsers

        public static List<string> UrlParse(string url)
        {
            List<string> list = new List<string>();
            string[] strs = url.Split(new char[] { '/', ':' });
            foreach (var s in strs)
            {
                if (s.ToLower().Contains("http")) { continue; }
                if (s.Length > 0) { list.Add(s); }
            }
            return list;
        }
        #endregion
    }
}
